package com.jms.fu.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.jms.fu.exception.DAOException;
import com.jms.fu.model.bo.TransactionBO;

public class ViewAdminPanelAction extends Action {
	private static Logger logger = Logger.getLogger(LoginAction.class);

	/**
	 * Method execute, called when executing the action
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 */
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		TransactionBO transactionBO = new TransactionBO();
		try {
			String buyApp,deposit,requestMoney,totalDownload,totalUpload;
			buyApp = transactionBO.getBuyAppToChart();
			deposit = transactionBO.getDepositToChart();
			requestMoney = transactionBO.getRequestMoneyToChart();
			totalDownload = transactionBO.getTotalDownloadToChart();
			totalUpload = transactionBO.getTotalUploadToChart();
			request.setAttribute("buyApp", buyApp);
			request.setAttribute("deposit", deposit);
			request.setAttribute("requestMoney", requestMoney);
			request.setAttribute("totalDownload", totalDownload);
			request.setAttribute("totalUpload", totalUpload);
			return mapping.findForward("success");
		} catch (DAOException e) {
			logger.error(e.getMessage());
			return mapping.findForward("failed");
		}
	}
}
